// author by welong
// zuowl@qq.com
// 2014-09-04  13:44
// PAT basic 1005

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void sort(int *result, int count)
{
	int i, j, temp;

	for(i = 0; i < count; i++)
	{
		for(j = 0; j < count-i-1; j++)
		{
			if(result[j] < result[j+1])
			{
				temp = result[j];
				result[j] = result[j+1];
				result[j+1] = temp;
			}
		}
	}
}

void show(int *result, int count)
{
	int i;

	for(i = 0; i < count; i++)
	{
		printf("%d", result[i]);
		if(i != count -1)
			printf(" ");
		else
			printf("\n");
	}
}

int main(int argc, char **argv)
{
	int i, j = 0, count, temp;
	int flag[101], *num, result[100];

	memset(flag, 0, sizeof(int)*101);	//must clr these memory, may cause test site 2,3,4,5 error
	scanf("%d", &count);
	num = (int*)malloc(sizeof(int) * count);

	for(i = 0; i < count; i++)
		scanf("%d", num+i);

	//mark flag array of covered number not bigger than 100
	for(i = 0; i < count; i++)
	{
		temp = num[i];
		if(flag[temp])	
			continue;	//be covered & have marked

		while(temp != 1)
		{
			if(temp%2 ==0)
				temp = temp/2;
			else
				temp = (temp*3 + 1)/2;

			if(temp <= 100)
			{
				if(flag[temp])
					break;
				else
					flag[temp] = 1;
			}
		}
	}
	
	//restore uncovered number in array result
	for(i = 0; i < count; i++)
	{
		if( !flag[num[i]] )
			result[j++] = num[i];
	}
	free(num);
	count = j;

	sort(result, count);
	show(result, count);

	return 0;
}